package com.zzxy.spring.po;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;

public class User implements BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean {
    private  String username;
    private  String password;
    private  int age;
    private  Address address;

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", age=" + age +
                ", address=" + address +
                '}';
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public User(String username, Integer age) {
        this.username = username;
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        System.out.println("2.set properties ...");
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
    public  User(){

        System.out.println("1.init bean");
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("3. bean name aware..."+s);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("4. bean factory aware");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("6. after properties set ...");
    }
    public  void  myInit(){
        System.out.println("7. custom init func ...");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("9. destroy ...");
    }
    public void myDestroy() {
        System.out.println("10. custom destroy func ...");
    }
}
